"use client"; import { UserInfoRep, UserVipInfo, Wallet } from "@/api/user"; import TipsModal, { ModalProps } from "@/components/TipsModal"; import { Link, useRouter } from "@/i18n/routing"; import { useWalletStore } from "@/stores/useWalletStore"; import { WalletEnum } from "@/types"; import { vipImages } from "@/utils/constant"; import { flatPoint, percentage } from "@/utils/methods"; import { ProgressBar, Toast } from "antd-mobile"; import { useTranslations } from "next-intl"; import Image from "next/image"; import { Fragment, useRef, useState } from "react"; type Props = { userInfo: UserInfoRep; userMoney: Wallet; userVip: UserVipInfo; }; const VipCard = (props: { userVip: UserVipInfo }) => { const { userVip } = props; const t = useTranslations("ProfilePage"); // Vip 图标 const vipIconElement = vipImages.map((item, index) => { if (item.leve === userVip.vip_level) { return ( {"vip"} {item.leve} ); } }); return (
{vipIconElement}
{/*
{userVip.vip_exp}xp
*/}
VIP{userVip.vip_level} {t("expTips", { exp: flatPoint(userVip.vip_score_exp - userVip.vip_exp), })} VIP {userVip.vip_next_level}
); }; const Progress = (props: { percent: number }) => { const { percent } = props; return (
{percent}%
); }; const WalletContent = (props: { percentage: number; type: string; difference: number; current: number; }) => { const { percentage, type, difference, current } = props; const t = useTranslations("ProfilePage"); return (
{type} R$ {current}
{t("modalBottomTips")} {difference.toFixed(2)}
); }; // 现金 const BalanceContent = (props: { wallet: Wallet }) => { const { wallet } = props; const t = useTranslations("ProfilePage"); return ( <> ); }; const BonusContent = (props: { wallet: Wallet }) => { const { wallet } = props; const t = useTranslations("ProfilePage"); return (

{t("bonusArticle")}

  • {t("bonusDesc1")}
  • {t("bonusDesc2")}
  • {t("bonusDesc3")}
); }; const FreeContent = (props: { wallet: Wallet }) => { const { wallet } = props; const t = useTranslations("ProfilePage"); return (

{t("freeArticle")}

  • {t("freeDesc1")}
  • {t("freeDesc2")}
); }; const ReplayContent = (props: { wallet: Wallet }) => { const { wallet } = props; const t = useTranslations("ProfilePage"); return (

{t("replayArticle")}

  • {t("replayDesc1")}
  • {t("replayDesc2")}
); }; const WalletCard = (props: { userMoney: Wallet }) => { const { userMoney } = props; const t = useTranslations("ProfilePage"); const tipsRef = useRef(null); const [tipsStatus, setTipsStatus] = useState("Bonus"); const modalHandler = (key: keyof typeof WalletEnum) => { setTipsStatus(key); tipsRef.current?.onOpen(); }; return ( <> {t("modalTitle")} } > {/*现金*/} {tipsStatus === WalletEnum.Balance ? : null} {/* 彩金*/} {tipsStatus === WalletEnum.Bonus ? : null} {/* 免费币 */} {tipsStatus === WalletEnum.Free ? : null} {/* 重玩币 */} {tipsStatus === WalletEnum.Replay ? : null}
modalHandler(WalletEnum.Balance)} >
{t("balance")} question
brl {userMoney.score || 0.0}
modalHandler(WalletEnum.Bonus)} >
{t("bonus")} question
brl {userMoney.point || 0.0}
modalHandler(WalletEnum.Free)} >
{t("free")} question
brl {userMoney.free_score || 0.0}
modalHandler(WalletEnum.Replay)} >
{t("replay")} question
brl {userMoney.lose_score || 0.0}
); }; export const ProfileHeader = (props: Props) => { const { userInfo, userVip } = props; const t = useTranslations("ProfilePage"); const wallet = useWalletStore((state) => state.wallet); const router = useRouter(); const handler = () => { if (!!wallet.score) { router.push("/withdraw"); } else { Toast.show("no money "); } }; return ( <>
{"avatar"}
{t("Conta")} {userInfo?.user_phone || ""}
{/*vipcard*/}
{t("Depósito")}

{t("Sacar")}

); };